package com.xzq.bugstack;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import java.nio.charset.Charset;
import java.util.Date;

/**
 * @Author xzq
 * @Description //TODO
 * @Date 2021/11/19 10:19
 * @Version 1.0.0
 **/
public class MyServerHandler  extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
       //接受Msg消息
        ByteBuf buf = (ByteBuf) msg;
        byte[] msgbytes = new byte[buf.readableBytes()];
        buf.readBytes(msgbytes);
        System.out.print(new Date()+"接收到消息:");
        System.out.println(new String(msgbytes, "gbk"));
    }
}
